import pandas as pd
import tushare as ts
import matplotlib.pyplot as plt
frame = ts.get_k_data('600339', start='2010-01-01', end='2020-10-31')

# 设置显示列和显示宽度
pd.set_option('display.max_columns', None)
pd.set_option('display.width', 500)
print(frame.head())

# # 法一
# frame.index = pd.to_datetime(frame['date'])
# frame = frame.drop(['date'], axis=1)  # axis=1 是删除列
# print(frame.head())

# 法二
frame.date = pd.to_datetime(frame['date'])
frame = frame.set_index('date')
print(frame.head())

frame1 = frame.shift(1)
print((frame.close - frame1.close).head(30))
